From: Patrik Svensson Date: Sat, 5 May 2018 14:17:59 +0000 (+0200) Subject: Made adjustments based on feedback from review. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~13^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=8da290805676dd5cbedf01041af1c889ac6e93e1;p=cargo.git Made adjustments based on feedback from review. --- diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 7309b394d..a2e35c3d5 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -26,7 +26,7 @@ pub fn run( }, }; -let bins: Vec<_> = pkg.manifest() + let bins: Vec<_> = pkg.manifest() .targets() .iter() .filter(|a| { @@ -48,12 +48,12 @@ let bins: Vec<_> = pkg.manifest() } if bins.len() == 1 { - let bin = bins.first().unwrap(); - match *bin.1 { - TargetKind::ExampleLib(..) => { + let &(name, kind) = bins.first().unwrap(); + match kind { + &TargetKind::ExampleLib(..) => { bail!( - "example target `{}` is a library and cannot be executed.", - bin.0 + "example target `{}` is a library and cannot be executed", + name ) }, _ => { } @@ -62,9 +62,7 @@ let bins: Vec<_> = pkg.manifest() if bins.len() > 1 { if !options.filter.is_specific() { - - let names : Vec<&str> = bins.into_iter().map(|bin| bin.0).collect(); - + let names: Vec<&str> = bins.into_iter().map(|bin| bin.0).collect(); bail!( "`cargo run` requires that a project only have one \ executable; use the `--bin` option to specify which one \ diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index bf2e37fe2..3744aa036 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -415,7 +415,7 @@ fn run_library_example() { p.cargo("run").arg("--example").arg("bar"), execs() .with_status(101) - .with_stderr("[ERROR] example target `bar` is a library and cannot be executed."), + .with_stderr("[ERROR] example target `bar` is a library and cannot be executed"), ); }